package edu.guet.chainofresponsiblity;

// 责任链模式: 使多个对象都有机会处理请求，从而避免请求的发送者和接受者之间的耦合关系。
//将这个对象连成一条链，并沿着这条链传递该请求，直到有一个对象处理它为止。
public class Main {

    public static void main(String[] args) {
        ConcreteHandler1 handler1 = new ConcreteHandler1();
        ConcreteHandler2 handler2 = new ConcreteHandler2();
        ConcreteHandler3 handler3 = new ConcreteHandler3();
        handler1.setSuccessor(handler2);
        handler2.setSuccessor(handler3);
        int[] requests = {2,5,14,22,18,3,27};

        for (int request:
             requests) {
            handler1.HandleRequest(request);
        }
    }
}
